* import_enh.do 11/18/2013
* This file Imports the Data from the ENH 1996 to 2000 into Stata Format
* Inputs: Files in Data/Original/encuestas de hogares/ENH 1996 to 2000
* Uses dofiles import_enh_year_trim where year and trim vary
* Outputs: Files in Data/Importable/ENH 

* Change log

/*	01/23/2015	JEP		Automatically change extensions p99 to uppercase
						Do not create docs local
*/		

clear all
version 13.1

* Project info
project, doinfo   
local master "`r(pdir)'"
local doname "`r(dofile)'" 

*Change

forv year=1996(1)2000 {
	forv trim=1(1)4 {
		cd "../../Data/Original/encuestas de hogares/ENH/`year'"
		*Unzip
		project, original("eht`year'`trim'.zip")
		unzipfile "eht`year'`trim'.zip", replace
		cd eht`year'`trim'
		* loc docs: dir . files "*.doc"		
		renfiles, insign("p99") outsign("P99")
		* Just in case		

		* Infix data
		
		* * Registro tipo 10 - Caracteristicas generales
		* 1996 1 id from 3 to 24
		* No depto, only municipio
		project, do("`master'/Code/Import/import_enh_`year'_`trim'.do")
		cd "`master'/Data/Original/encuestas de hogares/ENH/`year'"
		rmfiles, folder("eht`year'`trim'")
		rmdir "eht`year'`trim'"
		cd "`master'/Code/Import"
	}	
}




